package book;

import java.util.Date;

import javax.servlet.ServletException;

import common.TableManager;

public class RentalBean {

	private int id;
	private int bookId;
	private int memberId;
	private Date rentalDate;
	private Date returnDate;
	private Date returnPlanDate;
	private int reserveId;
	private BookBean bookBean;
	private member.MemberBean memberBean;
	private ReserveBean reserveBean;
	private String title;
	private String isbn;
	private boolean mailFlag;


	public Date getRentalDate() {
		return rentalDate;
	}
	public void setRentalDate(Date rentalDate) {
		this.rentalDate = rentalDate;
	}
	public Date getReturnDate() {
		return returnDate;
	}
	public void setReturnDate(Date returnDate) {
		this.returnDate = returnDate;
	}
	public Date getReturnPlanDate() {
		return returnPlanDate;
	}
	public void setReturnPlanDate(Date returnPlanDate) {
		this.returnPlanDate = returnPlanDate;
	}
	public int getId() {
		return id;
	}
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public String getIsbn() {
		return isbn;
	}
	public void setIsbn(String isbn) {
		this.isbn = isbn;
	}
	public void setId(int id) {
		this.id = id;
	}
	public int getBookId() {
		return bookId;
	}
	public void setBookId(int bookId) {
		this.bookId = bookId;
	}
	public int getMemberId() {
		return memberId;
	}
	public void setMemberId(int memberId) {
		this.memberId = memberId;
	}

	public int getReserveId() {
		return reserveId;
	}
	public void setReserveId(int reserveId) {
		this.reserveId = reserveId;
	}
	public BookBean getBookBean() throws ServletException {
		String sql = "select * from books where id = " + this.getBookId();
		this.bookBean=(BookBean)TableManager.getRecord(TableManager.BOOKS_TABLE, sql).getBean();
		return bookBean;
	}
	public member.MemberBean getMemberBean() throws ServletException {
		String sql = "select * from members where id = " + this.getMemberId();
		this.memberBean=(member.MemberBean)TableManager.getRecord(TableManager.MEMBERS_TABLE, sql).getBean();
		return memberBean;
	}
	public ReserveBean getReserveBean() throws ServletException {
		this.reserveBean=null;
		if(this.getReserveId() > 0) {
			String sql = "select * from reserves where id = " + this.getReserveId();
			this.reserveBean=(ReserveBean)TableManager.getRecord(TableManager.RESERVES_TABLE, sql).getBean();
		}
		return reserveBean;
	}
	public boolean isMailFlag() {
		return mailFlag;
	}
	public void setMailFlag(int mailFlag) {
		if(mailFlag == 0) {
			this.mailFlag = false;
		} else {
			this.mailFlag = true;
		}
	}
}
